//
//  ZCXActivityDetialViewController.m
//  LoveOfPet
//
//  Created by dllo on 15/11/14.
//  Copyright © 2015年 孔维. All rights reserved.
//

#import "ZCXActivityDetialViewController.h"
#import "ActivityModel.h"
#import "ZCXFirstActivityDetialTableViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
#define HEIGHT  [[UIScreen mainScreen]bounds].size.height / 667
#define WIDTH   [[UIScreen mainScreen]bounds].size.width / 375
@interface ZCXActivityDetialViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@end

@implementation ZCXActivityDetialViewController
- (void)dealloc{
    [_activity release];
    [_tableView release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64 , self.view.frame.size.width, self.view.frame.size.height - 64 * HEIGHT) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.showsVerticalScrollIndicator = NO;
    //注册Cell
    [self.tableView registerClass:[ZCXFirstActivityDetialTableViewCell class] forCellReuseIdentifier:@"firstactivitytableviewCell"];
    [self.view addSubview:self.tableView];
    [_tableView release];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ZCXFirstActivityDetialTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"firstactivitytableviewCell" forIndexPath:indexPath];
    cell.activity = self.activity;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat heigth = [ZCXFirstActivityDetialTableViewCell heigthOfmessageLabel:self.activity.message andFont:[UIFont systemFontOfSize:16 * WIDTH] andWidth:self.view.frame.size.width - 20 * WIDTH];
    return heigth * HEIGHT + 60 * HEIGHT;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIImageView *headerImageV = [[UIImageView alloc]init];
    [headerImageV sd_setImageWithURL:[NSURL URLWithString:self.activity.coverpath]];
    headerImageV.backgroundColor = [UIColor yellowColor];
    return headerImageV;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 150 * HEIGHT;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
